package com.yayo.mangement.controller.system;

import com.yayo.mangement.dto.SysRoleDTO;
import com.yayo.mangement.facade.SysRoleFacade;
import com.yayo.mangement.paging.Paging;
import com.yayo.mangement.response.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 
 * @author: Yayo
 * @date: 2020-08-07 14:10:31
 */
@RestController
@RequestMapping("/api/sysRole")
@Api(tags = "")
public class SysRoleController{

    @Autowired
    private SysRoleFacade sysRoleFacade;

    /**
    * 分页查询
    * @param pageNo 页码
    * @param pageSize 每页条数
    * @param params 查询条件
    */
    @GetMapping("/paging")
    public Response<Paging<SysRoleDTO>> paging(@ApiParam(name="页码", value="pageNo", example="1") Integer pageNo,
                                                    @ApiParam(name="页长", value="pageSize", example="10")Integer pageSize,
                                                    @ApiParam(name="参数", value="params")Map<String, Object> params){
        return sysRoleFacade.paging(pageNo,pageSize,params);
    }

    /**
    *  查询详情
    * @param id 查询条件：主键
    * @return
    */
    @GetMapping("/detail/{id}")
    public Response<SysRoleDTO> detail(@PathVariable Long id){
        return sysRoleFacade.detail(id);
    }

    /**
    *  新增
    * @param sysRoleDTO
    * @return
    */
    @PostMapping("/create")
    public Response create(@RequestBody SysRoleDTO sysRoleDTO){
        return sysRoleFacade.create(sysRoleDTO);
    }

    /**
     *  修改
     * @param sysRoleDTO
     * @return
     */
    @PutMapping("/update")
    public Response update(@RequestBody SysRoleDTO sysRoleDTO){
        return sysRoleFacade.update(sysRoleDTO);
    }

    /**
    *  删除
    * @param id 主键
    * @return
    */
    @DeleteMapping("/delete")
    public Response delete(@RequestBody Long id){
        return sysRoleFacade.delete(id);
    }


}